<?php
/**
 * @author 后台用户系统
 */
namespace backend\service\system;


use bc\service\base\Service;
use backend\models\system\UserModel;
use yii\web\Session;
use bc\util\AppConst;

class UserService extends Service
{
	
	public function __construct()
	{
		$this->model = new UserModel();
	}
	
	
	
	/**
	 * @param string $user
	 * @param string $password
	 * @return boolean
	 *
	 */
	public function auth($user, $password)
	{
		$userName = $user;
		//密码加密操作
		$encodePwd = md5($password . AppConst::ADMIN_ACCOUNT_KEY);
		
		$params = ['account' => $userName, 'pwd' => $encodePwd, 'status' => 1];
		$row = $this->getRow($params);
		
		
		if($row)
		{
			//login success
			$session = new Session();
			$session->set('admin', $row);
			return true;
		}
		return false;
	}
}